package test_model_base;

import static org.junit.Assert.*;

import java.sql.Date;

import junit.framework.Assert;
import junit.framework.TestCase;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.servlet.model.base.PassiveAccount;

public class PassiveAccountTest extends TestCase {
	private PassiveAccount pa;
	private Date birth;

	@Before
	public void setUp() throws Exception {
		super.setUp();
		birth = Date.valueOf("1988-01-26");
		pa = new PassiveAccount("jialin.liu@u-psud.fr", "jialin", "liu", birth);
	}

	@After
	public void tearDown() throws Exception {
		birth = null;
		pa = null;
	}

	@Test
	public void testPassiveAccount() {
		pa = new PassiveAccount();
		Assert.assertNull(pa.getEmail());
		Assert.assertNull(pa.getFirst_name());
		Assert.assertNull(pa.getLast_name());
		Assert.assertNull(pa.getBirth_date());
		Assert.assertEquals(false, pa.getIs_modified_birth_date());
		Assert.assertEquals(false, pa.getIs_modified_first_name());
		Assert.assertEquals(false, pa.getIs_modified_last_name());
	}

	@Test
	public void testPassiveAccountStringStringStringDate() {
		Date d = Date.valueOf("1988-11-04");
		pa = new PassiveAccount("jingjing.li@u-psud.fr", "jingjing", "li", d);
		Assert.assertEquals("jingjing.li@u-psud.fr",pa.getEmail());
		Assert.assertEquals("jingjing", pa.getFirst_name());
		Assert.assertEquals("li", pa.getLast_name());
		Assert.assertEquals(d, pa.getBirth_date());
		Assert.assertEquals(false, pa.getIs_modified_birth_date());
		Assert.assertEquals(false, pa.getIs_modified_first_name());
		Assert.assertEquals(false, pa.getIs_modified_last_name());
	}

	@Test
	public void testGetEmail() {
		Assert.assertEquals("jialin.liu@u-psud.fr",pa.getEmail());
	}

	@Test
	public void testGetFirst_name() {
		Assert.assertEquals("jialin", pa.getFirst_name());
	}

	@Test
	public void testGetLast_name() {
		Assert.assertEquals("liu", pa.getLast_name());
	}

	@Test
	public void testGetBirth_date() {
		Assert.assertEquals(birth, pa.getBirth_date());
	}

	@Test
	public void testGetIs_modified_first_name() {
		Assert.assertEquals(false, pa.getIs_modified_first_name());
	}

	@Test
	public void testGetIs_modified_last_name() {
		Assert.assertEquals(false, pa.getIs_modified_first_name());
	}

	@Test
	public void testGetIs_modified_birth_date() {
		Assert.assertEquals(false, pa.getIs_modified_birth_date());
	}

	@Test
	public void testSetIs_modified_first_name() {
		pa.setIs_modified_first_name(true);
		Assert.assertEquals(true, pa.getIs_modified_first_name());
	}

	@Test
	public void testSetIs_modified_last_name() {
		pa.setIs_modified_last_name(true);
		Assert.assertEquals(true, pa.getIs_modified_last_name());
	}

	@Test
	public void testSetIs_modified_birth_date() {
		pa.setIs_modified_birth_date(true);
		Assert.assertEquals(true, pa.getIs_modified_birth_date());
	}

	@Test
	public void testSetBirth_date() {
		Date d = Date.valueOf("1988-11-04");
		pa.setBirth_date(d);
		Assert.assertEquals(d, pa.getBirth_date());
	}

	@Test
	public void testSetFirst_name() {
		pa.setFirst_name("jingjing");
		Assert.assertEquals("jingjing", pa.getFirst_name());
	}

	@Test
	public void testSetLast_name() {
		pa.setLast_name("li");
		Assert.assertEquals("li", pa.getLast_name());
	}

}
